#!/bin/sh /etc/rc.common
START=99

run_njit()
{
	local enable
	config_get_bool enable $1 enable
	
	if [ $enable ]; then
		local username
		local password
		local ifname
		
		config_get username $1 username
		config_get password $1 password
		config_get ifname $1 ifname
	        njit-client $username $password $ifname &
                echo "NJIT Client has started."
		   
	fi
    
}

network( )
{
                      
	
           if logread |grep  "Interface 'wan' is now up"
           then
                echo "Network is ready."
           else
                echo "Network is not ready."
                sleep 13
                echo "Waiting for network ready."
           
                                
           fi
              
}
start()
{
	config_load njitclient
        config_foreach network
	config_foreach run_njit login
}

stop()
{
	killall njit-client
	killall udhcpc
	
	echo "NJIT Client has stoped."
}
